#ifndef __PARSE_TREE_H__
#define __PARSE_TREE_H__

#include "ParseNodes.h"
#include "NodeVisitor.h"

class Compilation {
	SP<ParseNode> _root;
public:
	enum ErrorCode { None = 0x0, EnvironmentBuilding = 0x1, TypeLinking = 0x2, HierarchyChecking = 0x4, Disambiguation = 0x8, TypeChecking = 0x10, Reachability = 0x20, CodeGeneration = 0x40};
	Compilation() : _root(new RootNode()), error(None) {}
	~Compilation() {}
	void Add(CompilationUnitNode *n) { ((ParentNode*)_root())->children.push_back(n);}

	void Compile();
	void Accept(NodeVisitor *visitor) { (*_root).Accept(visitor); }
	void AcceptAt(NodeVisitor *visitor, unsigned int i){ ((ParentNode*)_root())->children[i]()->Accept(visitor); };
	
	ErrorCode error;
};

#endif